﻿using IntelligentAgriculture.Contracts.Dto.Output.DeathModelsOutPut;
using IntelligentAgriculture.Contracts.Dto.Output.EarTagOutput;
using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.WebAPI.Application.Command.DeathModelCommand;
using IntelligentAgriculture.WebAPI.Application.Command.EarTageCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.DeathModelCommandHamdier
{
    public class DeathEagFindCommandHandler:IRequestHandler<DeathEagFindCommand, Results<DeathModelsOutPut>>
    {
        private readonly iDeathModelService _iDeathModelService;

        public DeathEagFindCommandHandler(iDeathModelService deathModelService)
        {
            _iDeathModelService = deathModelService;
        }

        

        public async Task<Results<DeathModelsOutPut>> Handle(DeathEagFindCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var list = await _iDeathModelService.Find(request.id);
                return Results<DeathModelsOutPut>.DataResult(list);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
